package com.hsingh.eclipse.mercury.extension.perspective;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.ui.IPerspectiveDescriptor;
import org.eclipse.ui.IPerspectiveRegistry;
import org.eclipse.ui.PlatformUI;

import com.hsingh.eclipse.mercury.extensionpoint.definition.ITask;
import com.hsingh.eclipse.mercury.extensionpoint.definition.ITaskProvider;

public class PerspectiveTaskProvider implements ITaskProvider {

  public PerspectiveTaskProvider() {}

  @Override
  public List<ITask> getTasks(IEvaluationContext context) {
    IPerspectiveRegistry registry = PlatformUI.getWorkbench().getPerspectiveRegistry();
    IPerspectiveDescriptor[] descriptors = registry.getPerspectives();

    ArrayList<ITask> list = new ArrayList<ITask>();
    for (IPerspectiveDescriptor d : descriptors) {
      list.add(new PerspectiveTask(d));
    }

    return list;
  }

}
